package com.hjh.gameforum.config;

import com.hjh.gameforum.interceptor.JwtInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private JwtInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/users/login",
                        "/users/register",
                        "/users/code",
                        "/users/login/phone",
                        "/doc.html",         // 添加Knife4j主页面
                        "/webjars/**",       // 静态资源
                        "/v3/api-docs/**",   // OpenAPI规范
                        "/swagger-resources/**",
                        "/error",          // 错误处理
                        "/topics",
                        "/topics/hot",
                        "/topics/*",      // 话题详情
                        "/replies",      // 评论列表
                        "/categories/all"

                );
    }
}